This repository has been archived by the owner on Oct 25, 2024. It is now read-only.
enhancement: revamp GraphQL query generation #1450
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR rewrites the indexer service's GraphQL query resolution layer.
The following breaking changes have been made:
@queryable
directive, each entity type has two queries generated for it which are the entry points for querying the indexer service:-- a query returning a singular object record, which take at most one argument that matches to a field in the entity. The chosen field must be annotated with the
@search
and@unique
directives.-- a query returning a
Connection
for the entity as described in the GraphQL Cursor Connections specification.-- A connection query will allow for the use of a sort input object as long as at least one of its entity's fields is sortable.
-- A connection query will allow for the use of a filter input object as long as at least one of its entity's fields is marked with the
@filter
directive.-- Paginated queries require a limit (by using the
first
keyword) and a sort order (by using theorder
keyword). Requesting the next or previous "page" can be done by passing a value from acursor
field from the response as a value for either theafter
orbefore
keywords, respectively.In addition to the above, the following non-breaking changes and fixes have been made:
@skip
and@include
directives as required by the relevant section of the GraphQL specification.@filter
directive for fields to denote which fields should be used for filtering connection queries.Display
traits.-- Queries are modeled through types and then converted to strings at the end.
hello-world
example to be a simple explorer of blocks with lists of transactions.fuel-indexer-graphql
module.dynamic.rs
to the GraphQL schema parsing step.format!()
calls in query generation.Testing steps
First, build the Fuel explorer example; you can use
bash scripts/utils/build_modules.bash
to build all examples. Then, start the Fuel explorer example with the service (be sure to adjust the Postgres details if they differ from the following command):Examples coming soon...
Notes
Yes, this PR is quite large. However, given that the block explorer will be served by an indexer backend, we needed to support as much GraphQL functionality as we possibly can; we do not have the luxury of enshrining certain types and queries as part of our code so we need to be able to support anything that a user may feasibly create.